package com.github.xuemingyu.springboot.acticitycloud.controller.api;

import com.bidanet.bdcms.core.bean.ApiResult;
import com.github.xuemingyu.springboot.acticitycloud.driver.dingtalk.DingTalkService;
import com.taobao.api.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: xmy
 * \* Date: 2019/1/24
 * \* Time: 9:56
 * \
 */
@RestController
@RequestMapping("/dingTalk")
public class DingTalkApiController {
    @Autowired
    private DingTalkService dingTalkService;

    @RequestMapping("/getAccessToken")
    public ApiResult getAccessToken() throws ApiException {
        String accessToken = null;
        try {
            accessToken = dingTalkService.getAccessToken();
        } catch (Exception e) {
            return ApiResult.error(e.getMessage());
        }
        return ApiResult.success(accessToken);
    }
}
